home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c
- Subject: Re: operator % - compiler error
- Date: 19 Mar 1996 20:35:45 GMT
- Organization: Borland International
- Message-ID: <4in5r1$j90@druid.borland.com>
- References: <4ihuuh$6ul@hatathli.csulb.edu> <4in0ih$o43@zeus.intellinet.com>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4in0ih$o43@zeus.intellinet.com>, JerryD@prodentec.com says...
- >
- >davidcho@csulb.edu (David Cho) wrote:
- >
- >>When I try to compile, I get an erro message for the following line:
-
- >
- >
- >>x=663608941*y%pow(2,32) /*I want remainder*/
- >
- >>But the error message says "illegal use of floating point". What does
- >>that mean? Isn't % used a an operator to calcuate the remainder?
- >
- >In Microsoft and Borland, the pow() function takes two doubles and
- >returns a double. The % operator can't take a double in either
- >argument, thus causing the error. Try casting it like such:
- >x=663608941*y%(long)pow(2,32);
-
- With Borland C++ 5.0 the result of casting pow(2,32) to a long is 0. I haven't
- tried it with Microsoft, but I would expect the same result. Technically the
- result of this conversion is undefined for any system that uses 32-bit longs,
- since the value cannot be represented in 32 bits.
-
-